פיתוח מ ע רכות תוכנ ה מבוססו ת Java אוהד ברזילי
|
|
- Rosa Lawrence
- 5 years ago
- Views:
Transcription
1 פיתוח מ ע רכות תוכנ ה מבוססו ת הבטי תקשורת במערכות תוכנה
2 על סדר היום תקש ורת בין מח שב ים תקש ורת ו חוטים מיקו מה ש ל התק שו רת ביישו ם ארכיטקטורות תק שו רת Client Server Peer to Peer RMI - תקשורת ללא תקשורת Web/Application Servers 2
3 פרוטוקול תקשורת פרוטוקול תקש ורת הוא מס מך המתאר תחלופת הודעות בי ן מח שבים המס מך מ תאר את: מבנה ההודעות השונות סדר הודעות חוקי הודעות שגיאה אפשריות המס מך אינו מתייח ס ל שפת התכנות ש שי מ שה לכתיבת ת וכניות המ דברות בעזרת הפרו טוקול 3
4 פרוטוקול תקשורת ניתן לשלב בין פרוטוקולים ע"י שליחת הודעות בתוך הודעות stack) (protocol כל אחת מההודעות מטפלת בהיבט אחר של המשלוח לדוגמא: במשלוח שורה ביישום chat ההודעה שנשלחת בפועל מכילה מידע גם על: איתור הכתובת, בקרת השגיאות, כרטיס הרשת ועוד... קיימים מספר ארגונים בעולם (ארגוני תקינה) אשר מרכזים את תהליך כתיבת המסמכים האלה. לדוגמא: קיימים ארגונים מסחריים אשר אינם מפרסמים את הפרוטוקול שבו הם משתמשים. לדוגמא: 4
5 Internet for dummies האינטרנט ה יא רשת מ חשבים ) = מחשבים + חוט ים) לכל מחשב ניתנת כתובת מספרים בין 0 ל- 255 Address) (IP המו ר כ בת מ- 4 (port) כל ת ו כנ ית ה רצ ה במח שב מקבלת מספר של וח ה בין 0 ל- 65,535 ניתן ליצור קשר עם מחשב המחובר לרשת ע"י ציון כתובתו ופניה אליו בהודעה המתאימה לפי הפרוטוקול בדרך כלל ע"י שי מוש בתו כנית הממ מ שת את הפרוטוקול 5
6 תקשורת ב ת וכנ י ת מ תקשרת עם הע ו לם הח י צ ונ י ע"י זרמ ים (streams) עם המקלדת: InputStreamReader in = new InputStreamReader(System.in); BufferedReader bin = new BufferedReader(in); String text = bin.readline(); קובץ: עם InputStreamReader in = new InputStreamReader( new FileInputStream("foo.txt")); BufferedReader bin = new BufferedReader(in); String text = bin.readline(); ננסה להשתמש באותה גישה בדיוק כדי לתקשר עם תוכנית מחשב אחרת במחשב אחר). לשם כך משתמש במחלקה Socket (שקע) (א ו ל י (Client - ב קיים חוסר סימטריה בין השני (שרת - (Server יוזם ההודעה הראשונה (לקוח ו ב י ן הצד 6
7 דוגמא: איך נשלח מחרוזת בין שני ( ) מחשבים? ServerSocket s = new ServerSocket(7); Socket clientsocket = s.accept(); BufferedReader in = new BufferedReader( new InputStreamReader( clientsocket.getinputstream())); String input = in.readline(); ב י יש ו מ י תקש ורת יש לכ ת ו ב שת י ת וכ נ י ו ת: ת וכנ י ת ס פק ו ת ו כנ ית לק וח. (הס פק ו הלק וח אי נם מר יצ ים א ת א ו תה ה ת וכנ י ת) I want to OK connect Socket s = new Socket(" 7); PrintWriter out = new PrintWriter(s.getOutputStream(), true); out.println( "hello there!"); 7
8 package examples.sockets; import java.io.*; import java.net.*; EchoClient public class EchoClient { public static void main(string[] args) throws IOException { Socket echosocket = null; PrintWriter out = null; BufferedReader in = null; try { String hostname = args[0]; echosocket = new Socket(hostName, 7); out = new PrintWriter(echoSocket.getOutputStream(), true); in = new BufferedReader( new InputStreamReader(echoSocket.getInputStream())); catch (UnknownHostException e) { System.err.println("unkown host"); System.exit(1); catch (IOException e) { System.err.println("Couldn't get I/O for " + "the connection to host"); System.exit(1); catch (ArrayIndexOutOfBoundsException aiobe) { System.err.println("wrong usage: enter hostname"); System.exit(1); 8
9 // establish an input stream to read from the standard input BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String userinput; while ((userinput = input.readline())!= null) { // writer line to output stream out.println(userinput); out.flush(); // print received echo result System.out.println("echo: " + in.readline()); // close streams and socket out.close(); in.close(); input.close(); echosocket.close(); Buisness Logic 9
10 class EchoServer { public static void main(string[] args) { ServerSocket serversocket = null; try { serversocket = new ServerSocket(7); catch (IOException ioe) { System.err.println("Couldn't listen on port 7"); System.exit(1); Socket clientsocket = null; try { clientsocket = serversocket.accept(); catch (IOException ioe) { System.out.println("Accept failed: 7"); System.exit(-1); EchoServer try { PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); BufferedReader in = new BufferedReader( new InputStreamReader(clientSocket.getInputStream())); String input = in.readline(); out.println(input); out.close(); in.close(); clientsocket.close(); serversocket.close(); catch (IOException ioe) { System.err.println("Couldn t communicate with client"); Buisness Logic 10
11 שיפור המימוש (chat שרת שלא יפול אחרי ההודעה הראשונה שרת שלא יפול אחרי הלקוח הראשון שרת שיודע לטפל בכמה לקוחות במקביל (כמ עט שרת בעיה: בעת הפעולות accept (המתנה ללקוח חדש), readline (קריאת שורה מזרם) או print (הדפסה לזרם) התוכנית נתקעת (blocked) ולא ניתן לבצע דברים אחרים "במקביל" כדי ליצור מקביליות יש להשתמש במנגנונים נוספים/חלופיים: חוטים (threads) שימוש בספריית תקשורת א-סינכרונית: java.nio 11
12 שרת echo מרובה חוטים אז איך נכתוב שרת echo מרו בה לקוחות? השרת יבצע לולאה של המתנה ללקוחות, לקוח חדש ייצור חוט חדש שיטפל בו עבור כל כל החוטים יריצו את אותו השרות לולאה שממתינה להודעה מהלקוח (כל חוט והלקוח שלו) ועונה לו מה חסר כ די להפוך את השרת ל שרת?chat 12
13 Multiple clients port 5077 client application server application client application
14 package examples.sockets; import java.net.*; import java.io.*; class MultiClientEchoServer { public static void main(string[] args) { ServerSocket serversocket = null; try { serversocket = new ServerSocket(7); catch (IOException ioe) { System.err.println("Couldn't listen on port 7"); System.exit(-1); while(true) { try { Socket clientsocket = serversocket.accept(); EchoClientHandler handler = new EchoClientHandler(clientSocket); (new Thread(handler)).start(); catch (IOException ioe) { 14
15 class EchoClientHandler implements Runnable { private Socket clientsocket; public EchoClientHandler(Socket clientsocket) { this.clientsocket = clientsocket; public void run() { try { PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); BufferedReader in = new BufferedReader( new InputStreamReader(clientSocket.getInputStream())); String input = null; while ((input = in.readline())!= null) { // read from the client out.println(input); // write to client out.close(); in.close(); clientsocket.close(); catch (IOException ioe) { System.err.println("couldn t communicate with client"); System.exit(-1); 15
16 (1) למה לא?Sockets בעיה: שי מו ש בפרו טוקול לא סטנדרטי התקשורת אמנם עוברת מעל פרוטוקולים סטנדרטים כגון IP, TCP, Ethernet ואולי אחרים (מאחורי הקלעים) אולם היישום עצמו מגדיר פרוטוקול משלו מספר 7, תוכן ההודעה הוא מחרוזת...) (שלוחה כדי להשתמש בתוכנית שלנו לקוחות (אנושיים) יצטרכו להריץ בעצמם את תוכנית הג'אווה: EchoClient 16
17 (2) למה לא?Sockets הטכנולוגיה תופסת חלק נכבד מהקוד, בעוד הלוגיקה העסקית (מה שהתוכנית באמת עושה) זניחה הדבר בולט בישומים פשוטים התקשורת והמקביליות הן היבטים (aspects) של היישום ולא נרצה לערב אותן עם הלוגיקה העסקית 17
18 (3) למה לא?Sockets למרות העושר שמספקת, ביישומים רבים זה אינו מוקד הפיתוח (פרט לשיקולי ביצועים) אנו מ ע ונ י ינ י ם לכת וב א ת ה י יש ום ללא תלות ב פר וט וק ול הת קשו רת שמעל י ו אנו ע וב ד ים לפ עמ ים אנו מע ונ י ינ ים ל תאר את הא ינטרא קצ י ה בי ן שנ י עצמ ים באותה צורה ב ין אם ה ם נמצאים ע ל אות ה מ כ ו נה וב י ן אם הם מתקשר ים ד רך הא ינטרנ ט נזכיר כי אחד מיסודות התכנות מונחה העצמים הוא העברת הודעות passing),(message כאשר הכוונה להפעלה של מתודות על עצמים 18
19 Variants of Networking Architectures
20 סוגים של לקוחות בבנ י ית ייש ו ם שרת- לק וח על המ תכנת ת להחל יט א יזו ל וג י ק ה תשב בשרת וא יזו בלק וח על מ ה משפ י ע ה החלט ה ז ו? מה ה קשר בי ן החלט ה זו ומ ו דל ה?MVC 20
21 הדפדפן הוא הלקוח גם ביישומ ים שאינם כוללים גלי שה באינטרנט מצאו את ההבדלים בין לקוחו ת ש ל MSN Messenger 21
22 הדפדפן הוא הלקוח ית רו נו ת הג י שה: סטנדרטי זמינות אין צורך בהתקנה או הרשאות (GUI, חסר ונ ות: הדפדפן מיועד לעבודה מעל HTTP חווית משתמש (פרוטוקול STATELESS קידוד ב HTML, CSS, Script Desktop כדי לשפר את חווית המשתמש בדפדפן לרמת Application נעשה שימוש בכמה טכנולוגיות Rich Internet Applications (RIA) 22
23 Asynchronous Script + XML (Ajax) אוסף טכנולוגיות המגדיל את התגובת י ות של יישומי אינטרנט 23
24 Ajax Fundamentals 24
25 במעלה מחסנית הפרוטוקולים מאפשרת עב ו ד ה ברמ ות שונ ו ת של פרוט ו ק ול התקש ו רת בה תאם לנד רש ע"י ה י י שום המחלקות Socket ו- ServerSocket לעבודה מעל TCP המחלקות DatagramPacket ו- DatagramSocket לעבודה מעל UDP המחלקה URL לעבודה מעל HTTP או FTP מחלקות לעבודה מעל פרוטוקולים מוצ פנים כגון SSLSocket 25
26 יתרונות בעבודה מעל HTTP אבטחה רוב הארגונים מאפשרים הודעות היוצאות ל port 80 שרותי Hosting אין צורך בשרת ייעודי אלא אפשר לתמרן שרתי WEB סטנדרטים כלים שימוש בכלי תוכנה סטנדרטים סביבות) (ספריות, מחלקות, 26
27 המחלקה URL עם או בלי קשר להפיכת שרתים לשרתי HTTP כדי להקל על כתיבת לקוחות בפרוטוקולים סטנדרטים java.net.url ftp) http, וכ י ו"ב) מ ספקת את המחלקה // Create some URL objects URL url = null, url2 = null, url3 = null; try { url = new URL(" // An absolute URL url2 = new URL(url, "catalog/books/javanut4/"); // A relative URL url3 = new URL(" " "index.html"); catch (MalformedURLException e) { /* Ignore this exception */ // Read the content of a URL from an input stream InputStream in = url.openstream(); 27
28 המחלקה URL ע"י שימוש במחלקה URLConnection ניתן לקבל פרטים נוספים על ההודעה Parsing) (HTTP Message כגון: // For more control over the reading process, get a URLConnection object URLConnection conn = url.openconnection(); // Now get some information about the URL String type = conn.getcontenttype(); String encoding = conn.getcontentencoding(); Date lastmodified = new Date(conn.getLastModified()); int len = conn.getcontentlength(); // If necessary, read the contents of the URL using this stream InputStream in = conn.getinputstream(); Scanner s = new Scanner(in); while(s.hasnextline()) System.out.println(s.nextLine()); 28
29 Peer to Peer Networks בתוכנות מסוימות יכולים מחשבים מסוימים לתפקד גם כשרת וגם כלקוח. מחשבים כאלו נקראים עמיתים (peers) (כגון (emule לדוגמא: רשתות שיתוף קבצים שאלה: איך תוכנית יכולה גם ליזום התקשרויות (לקוח) וגם לענות לבקשות נכנסות (שרת)? שאלה: איך ניתן ברשת peer-to-peer לדעת את כתובתו של המחשב המבוקש? שאלה: איך ניתן ב emule לדעת באיזה מחשב שמור קובץ מסוים? 29
30 The emule Network 30
31 The network is the computer * Consider the following program organization: method call SomeClass AnotherClass returned object computer 1 computer 2 If the network is the computer, we ought to be able to put the two classes on different computers (RPC) RMI is one technology that makes this possible * For an opposing viewpoint, see 31
32 Non-RMI Approach Server Machine Client Machine Bank b User defined code: Open socket Read & parse request Create response Send using protocol Deposit Request Response User-defined protocol User defined code: Open connection Format request Send using protocol Parse response 32
33 RMI Approach Server Machine Client Machine BankImpl b Automatically Generated Skeleton Request Response Automatically Generated Stub User defined: Bank b= // lookup b.deposit(accid, 200) Standard protocol 33
34 RMI Architecture 34
35 RMI Architecture Objects can be accessed remotely because they extend the Remote object RMI servers must be designed as an RMI server from scratch because it is not easy to take non-remote classes and make them remote A frequently used technique for creating sets of remote objects of the same type is to create a remote object factory that manages those objects and passes back references to those objects to clients 35
36 Web Services רעיון הפעלה של פונקציה על מחשב מרוחק עומד גם מאחורי Web Services Web Services בשונה מ MRI אינם תלויי שפת תכנות וניתן להפעיל אותם בעזרת פרוטוקולי טקסט (SOAP) בפורמט XML מעל HTTP או ישירות מעל (RESTful Web Services) HTTP נדון בהם בהרחבה בהמ שך ה קורס 36
37 Web/Application Servers J2EE מ ש מ ש כטכנו לוגיית ת ש תית ל שר תי RMI (EJB) שרתים אלו אשר נכתבו כ Containers ל- Components וככאלה מטפלים בכל היבטי התקשורת בעבור כותב ה Component 37
38 References Trail: Custom Networking Trail: RMI by Ann Wollrath and Jim Waldo Fundamentals of RMI Short Course by jguru RMI Tutorial by Ken Baclawski 38
"protocol stack! chat. Java
"protocol stack! chat # # $ "! $ http://www.ietf.org/rfc.html http://www.skype.com$ Internet for dummies "' &! ("IP Address! %%() "port! * +%#%%() * * % * (I/O "streams! InputStreamReader in = new InputStreamReader(System.in);
More informationNetworking Basics. network communication.
JAVA NETWORKING API Networking Basics When you write Java programs that communicate over the network, you are programming at the application layer. Typically, you don't need to concern yourself with the
More informationLab 1 : Java Sockets
Lab 1 : Java Sockets 1. Goals In this lab you will work with a low-level mechanism for distributed communication. You will discover that Java sockets do not provide: - location transparency - naming transparency
More informationהיצביט ומ - ןוכית ת וי נבת
תבני ו ת תיכון Patterns) (Design תבנ יו ת תיכון - מו טיבציה בחיי היום יום אנחנו מתארים דברים תוך שימוש בתבניות חוזרות: "מכונית א' היא כמו מכונית ב', אבל יש לה 2 דלתות במקום 4" "אני רוצה ארון כמו זה, אבל
More informationהקלחמ ה תמרב ת ונ וכ ת (static members ) יליזרב דהוא Java תפשב ם דקת מ תונכת ביבא ל ת תטיסרבינוא
ת כו נו ת ברמת ה מחלקה (static members) אוהד ברזילי תכנות מ תקד ם בשפת Java אוניברסיטת ת ל אביב static keyword שדות המוגדרים כ static מציינים כי הם מוגדרים ברמת המחלקה ולא ברמת עצם כל העצמים של אותה מחלקה
More informationNetwork Programming. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff
Network Programming by Vlad Costel Ungureanu for Learn Stuff Java Network Protocols 2 Java Network Protocols 3 Addresses Innet4Address (32-bit) 85.122.23.145 - numeric pentalog.com symbolic Innet6Address
More informationלוגיקה סינכרונית. מרצה: יפתח גילעדי, פלאפון: מיל:
לוגיקה סינכרונית מרצה: יפתח גילעדי, פלאפון: 057-8116766 מיל: g_iftah@yahoo.com לוגיקה סינכרוני ת סינכרונית לפי דופקי השעון, התהליך רץ. כל פ ו לס של ה ש ע ו ן היחידה הבסיסית ביותר בלוגיקה הסינכרונית הם
More informationתוכנה 1 סמסטר א' תשע"א
General Tips on Programming תוכנה 1 סמסטר א' תשע"א תרגול מס' 6 מנשקים, דיאגרמות וביטים * רובי בוים ומתי שמרת Write your code modularly top-down approach Compile + test functionality on the fly Start with
More informationמבוא למדעי המחשב תרגול 8 רשימה משורשרת כללית, Comparator
מבוא למדעי המחשב 2017 תרגול 8 רשימה משורשרת כללית, Comparator בתרגול היום. LinkedList בניית ההכללה מ- LinkIntList תרגול המבנה ושימושיו ממשקים: Comparator Sorted Linked List ל- LinkedList ע"י שימוש ב- Comparator
More informationעידן ה- Web 3.0. ל- Web Semantic ו- Web 3.0. Info April 2008
המעבר מט קסונו מיה ל אונ תו לו גיה וההבט חה של עידן ה- Web 3.0 ד"ר אורי חנני 1 April 2008 Info 2008 תו כ ן ה הרצאה 1.רקע לתחום ומושגי יס ו ד ד ר ך טקס ונ ומי ה ל אנתו לו ג י ה - מאינד ק ס, 2.עקרונו ת ומבנה
More informationלתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions
מבוא לתיכנות עם MATLAB 23427 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 203 Based on slides of Dr. Eran Eden, Weizmann 2008 ביטויים לוגיים דוגמא: תקינות
More informationלתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions
מבוא לתיכנות עם MATLAB 234127 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 2013 Based on slides of Dr. Eran Eden, Weizmann 2008 1 >>g = [89 91 80 98]; >>p
More informationתוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes
תוכנה 1 תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes class Outer { static class NestedButNotInner {... class Inner {... מחלקות מקוננות NESTED CLASSES 2 מחלקה מקוננת Class) )Nested
More informationהנכות 1 תואיגש םע תודדומתהו תואלול,םי : כרעמ 2 לוגרת
תוכנה 1 תרגול 2: מערכים, לולאות והתמודדות עם שגיאות מערכים מערכים Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices
More informationתוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות
תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות מערכים Array: A fixed-length data structure for storing multiple values of the same type Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5
More informationAlgorithms. Intro2CS week 5
Algorithms Intro2CS week 5 1 Computational problems A computational problem specifies an inputoutput relationship What does the input look like? What should the output be for each input? Example: Input:
More informationתוכנה 1 תרגול 2: מערכים ומבני בקרה
תוכנה 1 תרגול 2: מערכים ומבני בקרה 2 Useful Eclipse Shortcuts Ctrl+1 quick fix for errors, or small refactoring suggestions Ctrl+SPACE code content assist (auto-completion) Auto completion for main create
More informationASP.Net Web API.
ASP.Net Web API 1 מה זה? Web API View בלבד ולא Data אותו מממש השרת והוא מחזיר לקליינט API הוא Web API הבקשה והתשובה הן בפרוטוקול Http\Https הקליינטים של Web API יכולים להיות רבים : אפשר להשתמש גם בMVC
More informationהנכות 1 תואיגש םע תודדומתהו תואלול,םיכרעמ : לו 2 גרת
תוכנה 1 תרגול 2: מערכים, לולאות והתמודדות עם שגיאות מערכים Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices (start
More informationהנכות 1 םוכיס לוגרת 14 1
תוכנה 1 סיכום תרגול 14 1 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים במנשק הם תמיד מופשטים וציבוריים public interface MyInterface { public abstract int foo1(int i); int foo2(int i); The modifiers
More informationAdvanced Java Programming. Networking
Advanced Java Programming Networking Eran Werner and Ohad Barzilay Tel-Aviv University Advanced Java Programming, Spring 2006 1 Overview of networking Advanced Java Programming, Spring 2006 2 TCP/IP protocol
More informationChapter 19a Pronominal Suffixes Introduction
Chapter 19a Pronominal Suffixes Introduction You already know that when a pronoun is the direct object of a verb, it is commonly attached to the definite direct object marker א ת.נוּ).(י שׁ מ ר There is,
More informationתוכנה 1 * לא בהכרח בסדר הזה
תוכנה 1 תרגול 7: מנשקים, פולימורפיזם ועוד * לא בהכרח בסדר הזה 2 מנשקים מנשקים מנשק )interface( הוא מבנה תחבירי ב- Java המאפשר לחסוך בקוד לקוח. מנשק מכיל כותרות של מתודות המימוש שלהן. )חתימות( ללא קוד אשר
More informationתוכנה 1 תרגול מספר 13
1 תוכנה 1 תרגול מספר 13 ו- HashCode Equals עוד על טיפוסים מוכללים )Advanced Generics( חריגים )Exceptions( בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 ו- HASHCODE EQUALS 3 תזכורת: המחלקה Object package
More informationתוכנה 1 תרגול מספר 13
1 2 תוכנה 1 תרגול מספר 13 ו- HashCode Equals עוד על טיפוסים מוכללים )Advanced Generics( ו- HASHCODE EQUALS חריגים )Exceptions( בית הספר למדעי המחשב אוניברסיטת תל אביב 1 3 4 package java.lang; תזכורת: המחלקה
More informationהנכות 1 םוכיס לוגרת 13 1
תוכנה 1 סיכום תרגול 13 1 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים במנשק הם תמיד מופשטים וציבוריים public interface MyInterface { public abstract int foo1(int i); int foo2(int i); The modifiers
More informationפסיקות מערכות ובקרים. Components of a simple PC. I/O Device Types Block Devices. Typical Data Rates מהירות טיפוסית נתונים
מנהל התקנים DMA Introduction to Systems Programming מבוא לתכנות מערכות Device Manager גישה יש ירה לז י כר ו ן פסיקות קלט פלט Input-Output Devices, s, and I/O Architectures ניהול ציוד ה יקפי INTERRUPTS
More informationLecture 16: Linked Lists
Extended Introduction to Computer Science CS1001.py Lecture 16: Linked Lists Instructors: Benny Chor, Amir Rubinstein Teaching Assistants: Michal Kleinbort, Amir Gilad School of Computer Science Tel-Aviv
More informationמבוא לתכנות ב- JAVA תרגול 7
מבוא לתכנות ב- JAVA תרגול 7 רקורסיה - הקדמה הגדרה רקורסיבית: חדר הוא מסודר אם צד שמאל שלו מסודר שלו מסודר. וצד ימין שיטת פתרון רקורסיבית: פתרון מופעים פשוטים יותר של בעיה בכדי לפתור את הבעיה המקורית רקורסיה
More informationpublic static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1]));
Echo Client&Server Application EchoClient import java.net.*; import java.io.*; class EchoClient public static void main(string[] args) throws IOException if (args.length < 2) number>"); System.err.println("Usage:
More informationCOMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming
COMP 213 Advanced Object-oriented Programming Lecture 20 Network Programming Network Programming A network consists of several computers connected so that data can be sent from one to another. Network
More informationתוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב
תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב Today Static vs. Dynamic binding Equals / hashcode String Immutability (maybe) 2 Static versus run-time
More informationמצליחה. 1. int fork-bomb() 2. { 3. fork(); 4. fork() && fork() fork(); 5. fork(); printf("bla\n"); 8. return 0; 9. }
שאלה : (4 נקודות) א. ב. ג. (5 נקודות) הגדירו את המונח race-condition במדוייק לא להשמיט פרטים. ספקו דוגמא. (5 נקודות) מהו? Monitor נא לספק הגדרה מלאה. ( נקודות) ( נקודות) ציינו כמה תהליכים יווצרו בקוד הבא
More informationדף הדרכה ליצירת שרת/ לקוח עם GUI
דף הדרכה ליצירת שרת/ לקוח עם GUI בשיעורים הקודמים למדנו כיצד ליצור שרת לקוח פשוט, ויצירת טופס המכיל פקדים כלומר יצירת GUI למשתמש, בשיעור זה נרצה להראות את הדרך לשילוב בין השניים כלומר ליצור לקוח client
More informationתוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Array Creation and Initialization. Loop through Arrays
מערכים Array: A fixed-length data structure for storing multiple values of the same type תוכנה 1 Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 odds: 1 3 5 7 9 11 13 15 odds.length
More informationתוכנה 1 3 תרגול מס' מערכים ומבני בקרה
תוכנה 1 3 תרגול מס' מערכים ומבני בקרה מערכים Array: A fixed-length data structure for storing multiple values of the same type Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 odds:
More informationAdvanced Lab in Computer Communications Meeting 1 Layers Model, Codes, Ethernet. Instructor: Tom Mahler
Advanced Lab in Computer Communications Meeting 1 Layers Model, Codes, Ethernet Instructor: Tom Mahler Course Objective הודעות כלליות מעבר על דף מידע OSI Model Classical 7 layers model IP model Application
More informationלתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions
מבוא לתיכנות עם MATLAB 234127 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 2013 Based on slides of Dr. Eran Eden, Weizmann 2008 1 motivation Proper academic
More informationAmortized Analysis, Union-Find,
Practical Session No. 13 Amortized Analysis, Union-Find, AMORTIZED ANALYSIS Refers to finding the average running time per operation, over a worst-case sequence of operations. Amortized analysis differs
More informationתוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Loop through Arrays. Array Creation and Initialization
מערכים תוכנה 1 Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 תרגול 2: מערכים
More informationPrevious lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 URL
Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 What is a thread Why use multiple threads Issues and problems involved Java threads Natasha Alechina School of Computer
More informationMay 2007 Info 2007
חיפוש ויז ואלי מ בוסס אונ תו לו גיה ד"ר אורי חנני uri2@netvision.net.il May 2007 1 Info 2007 1.מושגי יסוד ורקע תו כ ן ה הרצאה מהי אנתול וגיה 2.ס בי בת הע בוד ה של החיפוש הויז ואלי 3.המחשו ת 4.אירו ע ים
More informationתור שימושים בעולם התוכנה
מבוא למדעי המחשב הרצאה : Queue, Iterator & Iterable תור מבנה נתונים אבסטרקטי תור שימושים בעולם התוכנה השימושים של תורים בעולם התוכנה מזכירים מאוד תורים במציאות: )VoIP( )YouTube( מקלדת שידור סרט באינטרנט
More informationIntroduction to Sockets 9/25/14
Introduction to Sockets 9/25/14 81 Remote communication Inter-process communication is at the heart of all distributed systems Using the network protocol stack on a node is the only way to communicate
More informationסעיף ב )11 נקודות( public synchronized void advance(staircase staircase) throws InterruptedException staircase!
גיליון תשובות מספר נבחן: 03( שאלה 1 סעיף א )10 @INV: 0
More informationprotocols September 15,
Contents SCI 351 4 Protocols, WWW Internet applications WWW, document technology Lennart Herlaar Original slides by Piet van Oostrum September 15, 2003 SCI351-4 1 X SCI351-4 1 X Internet applications How
More informationתרגול 4 פונקציות. מבנה של פונקציה: public static <return value type> <function name> (<arg1 type> <arg1>, <arg2 type> <arg2>, ) { <function body> }
נושאי התרגול: מה הן פונקציות הגדרת פונקציה,קריאה לפונקציה העברת ארגומנטים,החזרת ערך או void העברת משתנים פרימיטיביים ומערכים לפונקציה העמסה של פונקציות תרגול 4 פונקציות מוטיבציה לעיתים,אנו נזקקים לבצע
More informationהוראות חיבור e-port בפרוטוקול Art-Net למערכות תאורה שונות
30.06.2014 הוראות חיבור e-port בפרוטוקול Art-Net למערכות תאורה שונות המסמך נכתב ונערך ע"י רונן בן-הרוש עבור חברת דנאור מערכות תיאטרון ואולפנים בע"מ. http://www.danor.com הבדיקות נעשו באולם רובינא, בתיאטרון
More informationהנדסת תוכנה 11. מבוא לתבניות תיכון. se15b-yagel 1
הנדסת תוכנה 11. מבוא לתבניות תיכון se15b-yagel 1 מה היום? מבוא לתבניות תיכון Design Patterns הדגמה כולל BDD ו- Refactoring לפי הזמן, השלמת בקרת תצורה: Git Workflows בהמשך: עקרונות תיכון מונחה עצמים עבודה
More informationמערכים שעור מס. 4 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1
מערכים שעור מס. 4 דרור טובי דר' כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 למה מערכים? ברצוננו לאחסן בתוכנית ציוני בחינה כדי לחשב את ממוצע הציונים וסטיית התקן. נניח ש 30 סטודנטים לקחו
More informationThe Makor System for Typesetting Hebrew
Department of Mathematics, John Jay College, City University of New York ahoenig@suffolk.lib.ny.us Introduction I d like to describe this morning a new TEX-based system for typesetting Hebrew. I call this
More informationמחרוזות ב Java ותכנות מונחה בדיקות )Test Driven Development(
מחרוזות ב Java ותכנות מונחה בדיקות )Test Driven Development( תוכנה 1 תרגול 8 String Immutability Strings are constants String s = " Tea "; s = s.trim(); s = s.replace('t', 'S'); s 1 2 3 " Tea " "Tea" "Sea"
More informationמשתנים שעור מס. 2 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1
משתנים שעור מס. 2 דרור טובי דר' כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 תפקיד המשתנים הצהרה על משתנה השמת ערך במשתנה int a, b, c; a = 1234; b = 99; c = a + b; משתנים מאפשרים לנו לשמור
More informationCPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary
CPSC 441 Tutorial TCP Server Department of Computer Science University of Calgary TCP Socket Client Server Connection Request Server Listening on welcoming socket Client Socket Server Socket Data Simple
More informationרשימות דילוגים Skip Lists
Lecture6 of Geiger & Itai s slide brochure www.cs.technion.ac.il/~dang/courseds רשימות דילוגים Skip Lists Skip lists: A probabilistic Alternative to Balanced Trees, William Pugh, Communications of the
More informationTutorial 10. Introduction to C++ שימו
Introduction to ++ שימו תרגול זה אינו התרגול הרישמי של הקורס. הוא מבוסס על חוברת התרגולים אך מכיל שינויים, הסברים נוספים ודוגמאות שונות או נוספות. + + תוכנ ית רא שונה ב הכרו ת עם + + תרגול // First ++
More informationCSCD 330 Network Programming Spring 2018
CSCD 330 Network Programming Spring 2018 Lecture 7 Application Layer Socket Programming in Java Reading: Chapter 2, Java links Relevant Links page Some Material in these slides from J.F Kurose and K.W.
More informationDistributed Systems COMP 212. Lecture 8 Othon Michail
Distributed Systems COMP 212 Lecture 8 Othon Michail HTTP Protocol Hypertext Transfer Protocol Used to transmit resources on the WWW HTML files, image files, query results, Identified by Uniform Resource
More informationתרגילים ופתרונות בשפת - C הסתעפויות
תרגילים ופתרונות בשפת - C הסתעפויות כתב וערך: שייקה בילו תרגיל - 1 כתוב תוכנית שתקבל מהמשתמש שלושה מספרים, ותציג את הגדול מביניהם על המסך. #include void main() int mis1, mis2, mis3, max; printf("please
More informationמבוא למדעי המחשב הרצאה 12:
מבוא למדעי המחשב הרצאה 12: קבצים וחריגות (Exceptions) 1 ז יכרון משני ל עומת ז יכרון ר אשי מתקן לאכסון מידע במחשב דיסק קשיח, DVD,CD,Disk on Key וכולי... איטי יותר מהזיכרון הראשי זול יותר מהזיכרון הראשי
More informationשאלה 1 מהו הפלט של התוכנית הבאה:
תרגול חזרה שאלה 1 מהו הפלט של התוכנית הבאה: public sttic int wht(int n) { int i; int sum=0; if(n == 0) return 1; for (i=0; i
More informationEngineering Programming A
Engineering Programming A תרגול 5 25.11.2012 מערכים חד-מימדיים )תזכורת( לדוגמא: מערך בשם Arr בגודל 8 שאיבריו מטיפוס int 3 7 5 6 8 1 23 16 0 1 2 3 4 5 6 7 ב - arr[0] ב יושב ערך שהוא המספר השלם 3 arr[1]
More informationNir Adar
שפת Java למתכנתי ++C - חלק שני מסמך זה הורד מהאתר. אין להפיץ מסמך זה במדיה כלשהי, ללא אישור מפורש מאת המחבר. מחבר המסמך איננו אחראי לכל נזק, ישיר או עקיף, שיגרם עקב השימוש במידע המופיע במסמך, וכן לנכונות
More informationCSCD 330 Network Programming Winter 2019
CSCD 330 Network Programming Winter 2019 Lecture 7 Application Layer Socket Programming in Java Reading: Chapter 2, Java links Relevant Links page Some Material in these slides from J.F Kurose and K.W.
More information3 Dynamic Routing A (RIP and OSPF)
אוניברסיטת בן גוריון בנגב המחלקה להנדסת מערכות תקשורת רשתות תקשורת מחשבים - 2 קורס 37110211 מעבדה בתקשורת מחשבים 3 Dynamic Routing A (RIP and OSPF) בשבוע (29/11/2011) 5 בשבוע (13/12/2011) 7 מעבדה מספר
More informationפתרון מוצע לבחינת מה"ט ב_שפת c מועד אביב תשע"ח, פברואר 8102 מחבר: מר שייקה בילו, מכללת אורט רחובות
פתרון מוצע לבחינת מה"ט ב_שפת c מועד אביב תשע"ח, פברואר 8102 מחבר: מר שייקה בילו, מכללת אורט רחובות שאלה מספר 1 התוכנית מגדירה חמישה משתנים שלמים: השלושה הראשונים הם שלושה מצביעים - *s *t,i. j ושלושה נוספים
More informationJava.net Package and Classes(Url, UrlConnection, HttpUrlConnection)
Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection) Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in
More informationJAVA-BASED DYNAMIC WEB APPLICATION
JAVA-BASED DYNAMIC WEB APPLICATION BY AHMED MUSA MIDILA (PG/M.SC/07/42484) BEING A MSC PROJECT PRESENTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE AWARD OF A MASTER OF SCIENCE DEGREE IN COMPUTER
More informationCSCD 330 Network Programming Spring 2018
CSCD 330 Network Programming Spring 2018 Lecture 6 Application Layer Socket Programming in Java Reading for Java Client/Server see Relevant Links Some Material in these slides from J.F Kurose and K.W.
More informationהנכות 1 םוכיס לוגרת 13 1
תוכנה 1 סיכום תרגול 13 1 בחינה באופק! הבחינה תכלול את כל הנושאים שכיסינו במהלך הסמסטר: כל ההרצאות כל תרגולים כל תרגילי בית חומר סגור שאלות אמריקאיות 2 קצת על מנשקים מנשק יכול להרחיב שירותים במנשק הם תמיד
More informationמבוא למדעי המחשב תרגול 13: עצים בינאריים
מבוא למדעי המחשב תרגול 13: עצים בינאריים עצים בינאריים - הגדרה הגדרה: עץ בינארי הוא עץ ריק (בלי צמתים) או עץ המורכב משורש ושני תתי-עצים, הוא עץ בינארי. ימני ושמאלי, שכל אחד מהם תרגיל 1 עץ בינארי מסודר
More informationNetwork. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark
Network Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark jbb@ase.au.dk Outline Socket programming If we have the time: Remote method invocation (RMI) 2 Socket Programming Sockets
More informationCS 5010: PDP. Lecture 11: Networks CS 5010 Fall 2017 Seattle. Adrienne Slaughter, Ph.D.
Lecture 11: Networks CS 5010 Fall 2017 Seattle CS 5010: PDP Adrienne Slaughter, Ph.D. ahslaughter@northeastern.edu Northeastern University 1 Agenda Networking Northeastern University 2 INTRODUCTION Northeastern
More informationURL Kullanımı Get URL
Networking 1 URL Kullanımı Get URL URL info 2 import java.io.*; import java.net.*; public class GetURL { public static void main(string[] args) { InputStream in = null; OutputStream out = null; // Check
More informationPieter van den Hombergh Richard van den Ham. March 17, 2018
: Network : Network, Object Pieter van den Hombergh Richard van den Ham Fontys Hogeschool voor Techniek en Logistiek March 17, 2018 /FHTenL : Network March 17, 2018 1/21 Topics, Object Some everyday life
More informationCOMM1003. Information Theory. Dr. Wassim Alexan Spring Lecture 4
COMM1003 Information Theory Dr. Wassim Alexan Spring 2018 Lecture 4 Cryptology Cryptology is the most general term and it splits into two parts: Cryptography and Cryptanalysis Cryptography is the science
More informationתוכנה 1 * לא בהכרח בסדר הזה
תוכנה 1 תרגול 7: מנשקים, פולימורפיזם ועוד * לא בהכרח בסדר הזה 2 מנשקים מנשקים - תזכורת מנשק )interface( הוא מבנה תחבירי ב- Java המאפשר לחסוך בקוד לקוח. מנשק מכיל כותרות של מתודות )חתימות(. מימוש דיפולטיבי
More informationמבוא לתכנות בשפת C. Tzachi (Isaac) Rosen
מבוא לתכנות בשפת C מצביעים והקצאה דינאמית כתובות של משתנים לכל משתנה כתובת של המקום שלו בזיכרון כבר ראינו: שם של מערך הוא למעשה הכתובת של התא הראשון )באינדקס 0( של המערך להזכירכם: תא של מערך הינו משתנה
More informationTopic 10: Network Programming
Topic 10: Network Programming Client-Server Model Host and Port Socket Implementing Client Implementing Server Implementing Server for Multiple Clients Client-Server Model Clients Request a server to provide
More informationתרגול מס' 5: IO )קלט-פלט(
תוכנה 1 אוניברסיטת תל אביב תרגול מס' 5: IO )קלט-פלט( זרמי קלט וזרמי פלט Streams(,(Input & Output קוראים וכותבים, והשימוש בהם לצורך עבודה עם קבצים 2 Input/Output in Java פעולות קלט-פלט הן רכיב מרכזי בכל
More informationTCP connections. Fundamentals of Internet Connections Objectives. Connect to an Echo port. java.net.socket
Objectives TCP connections To understand programming of clients that connect to servers via TCP To understand the basics of programming of servers that accept TCP connections To practice programming of
More informationתוכנה 1 * לא בהכרח בסדר הזה
תוכנה 1 תרגול 7: מנשקים, פולימורפיזם ועוד * לא בהכרח בסדר הזה 2 מנשקים מנשקים מנשק )interface( הוא מבנה תחבירי ב- Java המאפשר לחסוך בקוד לקוח. מנשק מכיל כותרות של מתודות המימוש שלהן. )חתימות( ללא קוד אשר
More informationCS 355. Computer Networking. Wei Lu, Ph.D., P.Eng.
CS 355 Computer Networking Wei Lu, Ph.D., P.Eng. Chapter 2: Application Layer Overview: Principles of network applications? Introduction to Wireshark Web and HTTP FTP Electronic Mail: SMTP, POP3, IMAP
More informationSoftware 1. תרגול 9 Java I/O
Software 1 תרגול 9 Java I/O 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files Classes for serializing objects 2 Streams
More informationגיליון תשובות מספר נבחן:
גיליון תשובות מספר נבחן: 03( שאלה 1 סעיף א )02 (i) //@PRE: checkinv(other.getx(),other.gety(),other.getradius()) //@POST: getradius() other.getradius() >= // Math.max(Math.abs(getY()-other.getY()),Math.abs(getX()-
More informationCommunication Networks ( ) / Spring 2011 The Blavatnik School of Computer Science, Tel-Aviv University. Allon Wagner
Communication Networks (0368-3030) / Spring 2011 The Blavatnik School of Computer Science, Tel-Aviv University Allon Wagner Kurose & Ross, Chapter 3.5.5, 3.7 (5 th ed.) Many slides adapted from: J. Kurose
More information<exp> ::= <define> <cexp> <define> ::= ( define <var-decl> <cexp> ) / DefExp(var:VarDecl, val:cexp)
הנחיות כלליות: תאריך הבוחן: 10.5.2018 שם המרצה: מני אדלר,מיכאל אלחדד, ירון גונן מבחן בקורס: עקרונות שפות תכנות מס' קורס: 202-1-2051 מיועד לתלמידי: מדעי המחשב והנדסת תוכנה שנה: ב' סמסטר: ב' משך הבוחן: 2
More informationJava Programming Language Advance Feature
Java Programming Language Advance Feature Peter.Cheng founder_chen@yahoo.com.cn http://www.huihoo.com 2004-04 Huihoo - Enterprise Open Source http://www.huihoo.com 1 Course Goal The main goal of this course
More informationSockets and RMI. CS151 Chris Pollett Dec. 5, 2005.
Sockets and RMI CS151 Chris Pollett Dec. 5, 2005. Outline Echo Server with Multiple Clients Client pull/server push Remote Method Invocation Proxy Pattern Echo Server with Multiple Clients public class
More informationCS 351 Design of Large Programs Sockets Example
CS 351 Design of Large Programs Sockets Example Brooke Chenoweth University of New Mexico Spring 2019 Socket Socket(String host, int port) InputStream getinputstream() OutputStream getoutputstream() void
More informationIT101. File Input and Output
IT101 File Input and Output IO Streams A stream is a communication channel that a program has with the outside world. It is used to transfer data items in succession. An Input/Output (I/O) Stream represents
More informationDistributed Programming - Sockets
Distributed Programming - Sockets Piet van Oostrum May 25, 2009 Concurrency In praktische situaties krijgen we concurrency door: Processen Threads Interrupts (alleen intern in het O.S.) Processen Onafhankelijke
More informationב ה צ ל ח ה! אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כ"ה תשרי תשע"ח 15/10/17 שמות המורים: ציון סיקסיק מיועד לתלמידי : א'
אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כ"ה תשרי תשע"ח 15/10/17 שמות המורים: ציון סיקסיק א' ב- C תכנות מבחן ב: 202-1-9011 מס' הקורס : הנדסה מיועד לתלמידי : א' מועד קיץ סמ' שנה תשע"ז 3 שעות משך
More informationProgramming in C תרגול 8
Programming in C תרגול 8 1 1 נושאים מצביעים רקע אופרטורים על מצביעים מצביעים כפרמטרים לפונקציה הקצאת זיכרון דינאמית Malloc free מצביעים תאור הזיכרון של המחשב: ניתן לחשוב על זיכרון המחשב כעל רצף של תאים,
More informationObject-Oriented Analysis and Design
Object-Oriented Analysis and Design Session 2a: Structure Modeling Object-Oriented Analysis and Design 1 Outline 1. Objects and Classes 4 2. Basic Association Concepts.17 3. Class Diagrams and Object (instance)
More informationJava Socket Application. Distributed Systems IT332
Java Socket Application Distributed Systems IT332 Outline Socket Communication Socket packages in Java Multithreaded Server Socket Communication A distributed system based on the client server model consists
More information- מבחן. - 4 עבודות ב- JAVA. הגשה בזוגות דרך ה- System Submission
1 - מבחן. - 4 עבודות ב- JAVA 60% 40% הגשה בזוגות דרך ה- System Submission 2 UML Class Diagrams Packages Class Path JAR Files חלק ראשון: חלק שני: 3 An abstraction of software features A structure that singles
More informationתוכנה 1. תרגול מס' 3 עבודה עם מחרוזות )Strings( מתודות )Methods( העברת פרמטרים
תוכנה 1 תרגול מס' 3 עבודה עם מחרוזות )Strings( מתודות )Methods( העברת פרמטרים שלבי הפיתוח - חזרה קצרה ישנם שני שלבים נפרדים: שלב פיתוח התוכנית בשלב זה אנו משתמשים במהדר )קומפיילר( כדי להמיר קבצי.java )קבצי
More informationSchool of Informatics, University of Edinburgh
CS1Bh Lecture Note 16 Case Study: Client/Server In this case study we look at providing a slightly more realistic client/server application and explore some of the issues that arise in this context. Specifically
More informationNetworking Code CSCI 201 Principles of Software Development
Networking Code CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Server Networking Client Networking Program Outline USC CSCI 201L Server Software A server application
More information